use serde::Deserialize;
use serde::Serialize;
use ts_rs::TS;
use yata::core::PeriodType;

use super::IndicatorActionWrap;

///
/// Struct to hold the results of Struct yata::indicators::PivotReversalStrategy
///
///
#[derive(Serialize, Deserialize, Default, Debug, TS, Clone)]
#[ts(export)]
pub struct PRS {
    /// 1 signal
    /// main pivot signal
    /// When low pivot happens, returns full buy signal.
    /// When high pivot happens, returns full sell signal.
    /// Otherwise returns no signal.
    /// The signals are most reliable if they occur after a strong trend. If the trend is weak, so is the signal.
    pub signal0: Option<IndicatorActionWrap>,
    // No values
}

/// Configuration
#[derive(Serialize, Deserialize, Debug, TS, Clone, Copy)]
#[ts(export)]
pub struct PRSConfig {
    ///left: PeriodType
    ///How many periods should left before pivot point.
    ///
    ///Range in [1; PeriodType::MAX-right).
    pub left: PeriodType,

    ///right: PeriodType
    ///How many periods should appear after pivot point.
    ///
    ///Range in [1; PeriodType::MAX-left).
    pub right: PeriodType,
}

impl Default for PRSConfig {
    fn default() -> Self {
        Self {
            left: 2,
            right: 2,
            // source: Source::Close,
        }
    }
}
